// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import echarts from 'echarts'
import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueCookies from 'vue-cookies'
import store from '@/vuex/store'

Vue.use(ElementUI)
Vue.use(VueCookies)

Vue.config.productionTip = false
Vue.prototype.bus = new Vue()
Vue.prototype.$echarts = echarts
Vue.prototype.$axios = axios


// 访问控制
router.beforeEach(function (to, from, next) {
  if (to.meta.needLogin) {
    console.log('需要登录访问')
    try {
      this.$cookies.get("cid")
      console.log('有cookie信息')
      next();
    }catch (e) {
      console.log('无cookie信息')
      next({
        path:'/'
      });
    }
  } else {
    console.log('无需登录访问')
    next();
  }
})




new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App),
  components: { App },
  template: '<App/>'
})
